var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var cors = require('cors')

require('./database/connect')//连接数据库

var {checktoken} = require('./utils/checktoken')    //token验证

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var stuRouter = require('./routes/stu');
var userinfo =require('./routes/userinfo')
var tuserRouter = require('./routes/tuser')

var app = express();

app.use(cors())
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/stu' ,stuRouter);
app.use('/gettuser',tuserRouter);
// app.use('/userinfo',(req,res,next)=>{checktoken(req,res,next)} ,userinfo);

module.exports = app;